import type { Publicize } from '@/api/modules/lcd/publicize';
import { DEVICE_TYPE_ENUM, SCHEDULE_TYPE_ENUM } from '@/enum/system';
import { getTimeZone } from '@/utils/common/format';
import type { Rule } from 'ant-design-vue/es/form';
import { currentStep } from '../pages/advertisement/data';

const formObj: Publicize = {
  name: '',
  publicizeSize: '800*450',
  materials: [],
  objects: [],
  publishTime: [],
  timeZone: getTimeZone(),
  publishStatus: '0',
  timeType: SCHEDULE_TYPE_ENUM.ONE_TIME,
  type: DEVICE_TYPE_ENUM.CUSTOM,
  week: [],
};
export const form = ref({
  ...formObj,
});

export const formRef = ref();

export const resetForm = () => {
  currentStep.value = 0;
  // @ts-ignore
  form.value = undefined;
  form.value = {
    ...formObj,
  };
};
export const formRules: Record<keyof Publicize, Rule[]> = {
  name: [{ required: true }],
  publicizeSize: [],
  materials: [],
  type: [],
  objects: [],
  id: [],
  publishTime: [],
  timeZone: [],
  publishStatus: [],
  timeType: [],
  week: [],
};
